package com.ww.event.observer;
/**
 *
 **/

import java.util.Observable;

/**
 * @Author weiwei
 * @Date 2021-08-31 11:25
 * @description
 **/
public class ObservableDemo {

    

    public static void main(String[] args) {
        MyObservable observable = new MyObservable();
        observable.addObserver((o, msg) -> {
            System.out.printf("observable[%s] notifies a message[%s]\n",o,msg);
        });

        observable.notifyObservers("Hello,World");
    }
    
}

class MyObservable extends Observable{
    
    
    @Override
    public void notifyObservers(Object msg){
        setChanged();
        super.notifyObservers(msg);
    }
}
